package com.falm.picturebackend.util;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import de.mkammerer.argon2.Argon2;
import de.mkammerer.argon2.Argon2Factory;
import org.springframework.beans.factory.annotation.Value;

/**
 * 加解密工具
 * 
 * @author Administrator
 */
public class SecurityUtil {

    private static final Argon2 argon2 = Argon2Factory.create();

    /**
     * 迭代次数
     */
    @Value("${argon2.iterations}")
    private static final int iterations = 2;

    /**
     * 缓存大小
     */
    @Value("${argon2.memory}")
    private static final int memory = 65536;

    /**
     * 线程数
     */
    @Value("${argon2.parallelism}")
    private static final int parallelism = 1;

    public static String encrypt(String str) {
        return argon2.hash(iterations, memory, parallelism, str);
    }

    public static boolean verify(String hashPassword, String password) {
        return argon2.verify(hashPassword, password);
    }
}